<form action="" method="post">
    用户名：<input type="text" name="username">
    <input type="submit" name="sub" value="提交">
</form>
<?php
/**
 * User: lie
 * Date: 2020/12/4 14:32
 * Title: 统一英文注册用户首字母的大小写
 * Description:
 * Error:
 */
if ($_POST['sub']) {
    echo "首字母统一大小写：";
    echo ucfirst($_POST['username']);
}
echo "<hr>";
// 通过substr 与 ASCII 码转换大小写
if ($_POST['sub']) {
    $username = $_POST['username'];
    $tusername =  trim($username);
    $keywold = substr($tusername, 0,1);
    $ascii = (ord($keywold));
    if ($ascii >96 && $ascii < 123) {
        $ascii = chr($ascii-32);
    }
}